<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <title>敏感词管理</title>
    <link href="/js/bstable/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="/js/bstable/css/bootstrap-table.css" rel="stylesheet" type="text/css">
    <link href="/css/table.css" rel="stylesheet" type="text/css">

    <script src="/js/vue.js"></script>
    <script src="/js/axios.min.js"></script>

    <script src="js/jquery/jQuery-2.2.0.min.js"></script>
    <script src="js/bstable/js/bootstrap.min.js"></script>
    <script src="js/bstable/js/bootstrap-table.js"></script>
    <script src="js/bstable/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="js/layer_v2.1/layer/layer.js"></script>
    </head>
    <body style="background-color: #ecf0f5;font-family: 微软雅黑;color: #475059;min-width: 1000px;overflow: auto">
    <div id="app">
    <div class="notice_main">
        <div class="notice_check">
            <div class="notice_nav r_right">
                <a href="/word_add.html" class="btn btn-default" >添加敏感词</a>
            </div>
        </div>
       </div>
    <table class="table table-bordered  table-hover">
        <tr>
            <th type="radio">▢</th>
            <th>序号</th>
            <th>敏感词</th>
            <th>替换词</th>
            <th>发表时间</th>
            <th>操作</th>
        </tr>
        <tr v-for="(item,index) in swordsList">
            <td><label>
                <input type="checkbox"   id="inlinecheckbox1" value="true">
            </label></td>
            <td> {{index+1}} </td>
            <td>{{item.words}}</td>
            <td>{{item.category}}</td>
            <td>{{item.create_date}}</td>
            <td> <a   @click="updateSwords(item.word_id)">修改</a> |  <a   @click="delSwords(item.word_id)">删除</a></td>
        </tr>
    </table>
    </div>
    </body>
</html>
<script>
    new Vue({
        el:"#app",
        data:{
            swordsList:[],
        },
        methods:{
            updateSwords: function (word_id) {
                alert(word_id)
                window.localStorage.setItem("sid", word_id);
                location.href = "word_update.html"
            },
            delSwords: function (word_id){
                alert(word_id)
                window.localStorage.setItem("sid", word_id);
                location.href="word.html"
                axios.get('/swords/del',{
                    params:{
                        word_id: word_id
                    }
                }).then(function (response){
                    console.log(response.data);
                })
                    .catch(function (error){
                        console.log(error);
                    });
            }
        },
        mounted() {
            _this = this
            axios.get('/swords/list')
                .then(function (response) {
                    _this.swordsList=response.data;
                    console.log(response.data);
                })
                .catch(function (error){
                    console.log(error);
                });
        }
    })
</script>